package com.example.springbootsfzy.service.sunnan;

import com.example.springbootsfzy.domain.PsychologicalQaQuestions;
import com.example.springbootsfzy.domain.PublicWelfareActivities;
import com.example.springbootsfzy.mapper.PsychologicalQaQuestionsMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PsychologicalQaQuestionsService {
    @Autowired
    private PsychologicalQaQuestionsMapper psychologicalQaQuestionsMapper;

    /**
     * 根据发布时间查询心理测评问题
     * @param pageNum 当前页码
     * @param pageSize 每页显示的数量
     * @return PageInfo
     */
    public PageInfo<PsychologicalQaQuestions> selectPaginatedQuestionsByQ(int pageNum, int pageSize) {
        // 使用 PageHelper.startPage 设置分页
        PageHelper.startPage(pageNum, pageSize);
        Page<PsychologicalQaQuestions> psychologicalQaQuestions = psychologicalQaQuestionsMapper.selectPaginatedQuestionsByQ();
        return new PageInfo<>(psychologicalQaQuestions);
    }

    /**
     * 根据回复时间查询心理测评问题
     * @param pageNum 当前页码
     * @param pageSize 每页显示的数量
     * @return PageInfo
     */
    public PageInfo<PsychologicalQaQuestions> selectPaginatedQuestionsByR(int pageNum, int pageSize) {
        // 使用 PageHelper.startPage 设置分页
        PageHelper.startPage(pageNum, pageSize);
        Page<PsychologicalQaQuestions> psychologicalQaQuestions = psychologicalQaQuestionsMapper.selectPaginatedQuestionsByR();
        return new PageInfo<>(psychologicalQaQuestions);
    }
    /**
     * 根据id查找心理测评问题
     */
    public PsychologicalQaQuestions selectQuestionById(int id) {
        return psychologicalQaQuestionsMapper.selectQuestionById(id);
    }


    /**
     * 根据回复数量查询心理测评问题
     * @param pageNum 当前页码
     * @param pageSize 每页显示的数量
     * @return PageInfo
     */
    public PageInfo<PsychologicalQaQuestions> selectPaginatedQuestionsByT(int pageNum, int pageSize) {
        // 使用 PageHelper.startPage 设置分页
        PageHelper.startPage(pageNum, pageSize);
        Page<PsychologicalQaQuestions> psychologicalQaQuestions = psychologicalQaQuestionsMapper.selectPaginatedQuestionsByT();
        return new PageInfo<>(psychologicalQaQuestions);
    }


    /**
     * 添加心理测评问题
     * @param psychologicalQaQuestions 心理测评问题对象
     * return int 响应结果
     */
    public int addPsychologicalQaQuestions(PsychologicalQaQuestions psychologicalQaQuestions) {
        return psychologicalQaQuestionsMapper.insertSelective(psychologicalQaQuestions);
    }

    /**
     * 删除心理测评问题
     * @param id 心理测评问题id
     * return int 响应结果
     */
    public int deletePsychologicalQaQuestions(int id) {
        return psychologicalQaQuestionsMapper.deleteByPrimaryKey(id);
    }

    /**
     * 修改心理测评问题
     */
    public int updatePsychologicalQaQuestions(PsychologicalQaQuestions psychologicalQaQuestions) {
        return psychologicalQaQuestionsMapper.updateByPrimaryKey(psychologicalQaQuestions);
    }
}
